import { Toast } from "antd-mobile";
import React, { useEffect } from "react";
import { Navigate } from "react-router-dom";
function Dao(Com) {
  return () => {
    let userId = localStorage.getItem("userId");

    useEffect(() => {
      if (!userId) {
        Toast.show({
          content: "请先登录后再访问",
          duration: 2000,
        });
      }
    }, [userId]);

    if (userId) {
      return <Com />;
    } else {
      return <Navigate to="/login" />;
    }
  };
}

export default Dao;
